script_enemy_main{

let phase=rand_int(0,1);

let character="Tomoko";
let cutin=character;
let dispelled=0;
let spellcards=1;
let spellcardnumber=1;
let damagerate=10;
let outfit=1;
outfit=(128*outfit)-128;
let usespell=0;
let bgfade=0;
let frame=0;
let time=0;
let miny=GetClipMinY; let maxy=GetClipMaxY; let minx=GetClipMinX; let maxx=GetClipMaxX;
let cx=GetCenterX; let cy=GetCenterY;

let SEsparkle=("script\SoundEffects\magics5.wav");
let SEtweet=("script\SoundEffects\magics1.wav");

let BG1=("\script\Images\BackgroundLayers\Tomoko1.png");
let GRboss=("\script\Images\CharacterSprites\Tomoko.png");

#include_function "script/Functions/SetSpellcardCommonData.txt";
#include_function "script/Functions/SpellcardNameLoad.txt";
#include_function "script/Functions/HealthBarLoad.txt";
#include_function "script/Functions/CutInLoad.txt";

@Initialize{
	LoadUserShotData("script\shots\ShotsTomoko1.txt");

	LoadSE("script\SoundEffects\magics5.wav");
	LoadSE("script\SoundEffects\magics1.wav");

	LoadGraphic("\script\Images\BackgroundLayers\Tomoko1.png");
	LoadGraphic("\script\Images\CharacterSprites\Tomoko.png");

	SetScore(500000);
	SetLife(250);
	SetTimer(35);
	SetInvincibility(120);
	SetDamageRate(10,10); 
	SetEnemyMarker(true);
	MagicCircle(true);
	#include_function "script/Functions/Focus.txt";
	Focus(character);
	SetEffectForZeroLife(60,100,1);

	SetX(GetCommonData("Boss1X"));
	SetY(GetCommonData("Boss1Y"));
	SetCommonData("Boss1Vanish",1);
	SetMovePosition02(cx,miny+100,50);
}
	
@MainLoop{

SetCollisionA(GetX,GetY,16);
SetCollisionB(GetX,GetY,16);
SetShotAutoDeleteClip(255,255,255,255);

Weakness(character);
#include_function "script/Functions/Weakness.txt";
if(GetCommonData("BombOn")==0){ damagerate=10; }
if(GetCommonData("BombOn")==1){ damagerate=5; }
SetDamageRate(damagerate*weaken,damagerate*weaken);

let difficulty="";
if(GetCommonDataDefault("Difficulty",3)==1){ difficulty="Easy"; }
if(GetCommonDataDefault("Difficulty",3)==2){ difficulty="Normal"; }
if(GetCommonDataDefault("Difficulty",3)==3){ difficulty="Hard"; }
if(GetCommonDataDefault("Difficulty",3)==4){ difficulty="Lunatic"; }

SpellcardName("Birth [Circle Of Life] ("~difficulty~")",spellcardnumber);
HealthBar();
Portrait(cutin,1);

if(time%200==0 && time>=60){
	if(GetPlayerX>minx+50 && GetPlayerX<maxx-50){
	SetMovePosition01(GetPlayerX+rand(-30,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX<=minx+50){
	SetMovePosition01(GetPlayerX+rand(15,30),rand(miny+60,miny+120),1.5);
	}
	if(GetPlayerX>=maxx-50){
	SetMovePosition01(GetPlayerX-rand(15,30),rand(miny+60,miny+120),1.5);
	}
}

if((time+240)%320==0 && time>=60){
let pt1=0;
let pt2=1;
let a=0;
let b=0;
let c=0;
usespell=60;
let color=0;
	loop(3){
	SetShotColor(255-color,255-color,255-color);
		loop(18){
		CreateShotA(pt1,GetX+20,GetY-45,0);
		if(phase%2==0){ SetShotDataA(pt1,0,2.3+b,a+c,0,-0.03,0,177); }
		if(phase%2!=0){ SetShotDataA(pt1,0,2.3+b,a+c,0,-0.03,0,178); }
		SetShotKillTime(pt1,121);
			loop(1){
			CreateShotA(pt2,0,0,0);
				if(phase%2==0){
				SetShotDataA(pt2,0,0,rand(0,360),rand(-2,2),0.01,4,9);
				SetShotDataA(pt2,120,NULL,NULL,0,0.01,4,9);
				}
				if(phase%2!=0){
				SetShotDataA(pt2,0,0,rand(0,360),rand(-2,2),0.01,4,10);
				SetShotDataA(pt2,120,NULL,NULL,0,0.01,4,10);
				}
			AddShot(120,pt1,pt2,0);
			}
		FireShot(pt1);
		a+=360/18;
		}
	b+=0.5;
	c+=6.66;
	color+=30;
	}
PlaySE(SEsparkle);

phase++;
}

if((time+120)%320==0 && time>=60){ PlaySE(SEtweet); }


time++; frame++;
if(usespell>0){ usespell--; } if(usespell<0){ usespell++; }
SetCommonData("Boss1X",GetX); SetCommonData("Boss1Y",GetY);

#include_function "script/Functions/SpellcardName.txt";
#include_function "script/Functions/HealthBar.txt";
#include_function "script/Functions/CutIn.txt";
}

@BackGround{
	if(bgfade<255){ bgfade+=5; }

	SetTexture(BG1);
	SetAlpha(bgfade/2);
	SetGraphicScale(2,2);
	SetGraphicRect(0,0,350,350);
	SetGraphicAngle(0,0,time/3);
	DrawGraphic(cx,cy-70);
}

@DrawLoop{
	SetGraphicScale(1,1);
	SetTexture(GRboss);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetRenderState(ALPHA);

	if(usespell>=1){ SetGraphicRect(384,outfit,512,outfit+128); }
	if(usespell<=-1){ SetGraphicRect(512,outfit,640,outfit+128); }
	if(usespell==0){
		if(GetSpeedX<=0.5 && GetSpeedX>=-0.5){ SetGraphicRect(0,outfit,128,outfit+128); }
		else if(GetSpeedX<-0.5){ SetGraphicRect(128,outfit,256,outfit+128); }
		else if(GetSpeedX>0.5){ SetGraphicRect(256,outfit,384,outfit+128); }
	}
	DrawGraphic(GetX,GetY);
}
 
@Finalize{
	SetCommonData("Conversation",1);

	NewPointData(spellcardnumber,GetCommonData("Difficulty"));
	#include_function "script/Functions/Main Menu/SpellcardDataAndPoints.txt";
}

}